﻿
@model IEnumerable<EUTmvc.Models.Admin.AdminNewsViewAction>
<div class="panel panel-default">
    <div class="panel-heading">
        Tổng hợp tin tức
    </div>
    <!-- /.panel-heading -->
    <div class="panel-body">
        @if (Model.Count() == 0)
        {   
            <p><a href="@Url.Action("New", "AdminNewsAction")" class="btn btn-primary pull-left"><span class='glyphicon glyphicon-plus'></span></a></p><br />
            <p class="text-danger" style="margin: 10px 0 0">Không có dữ liệu tin tức! Xin hay cập nhật dữ liệu</p>
        }
       @if (Model.Count() > 0)
        {
            <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                <thead>
                    <tr>
                        <th>STT</th>
                        <th>@Html.DisplayNameFor(model => model.Title)</th>
                        <th>@Html.DisplayNameFor(model => model.CreateBy)</th>
                        <th>@Html.DisplayNameFor(model => model.CreateDate)</th>
                        <th>
                            <a href="@Url.Action("New", "AdminNewsAction")" class="btn btn-primary pull-right"><span class='glyphicon glyphicon-plus'></span></a>
                        </th>
                     </tr>
                 </thead>
                 <tbody>
                @{int i = 0;}
                @foreach (var item in Model)
                {
                    i++;
                    <tr>
                        <td>
                            @i
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Title)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.CreateBy)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.CreateDate)
                        </td>
                        <td>
                            <div class="pull-right">
                                <a href="@Url.Action("Edit", "AdminNewsAction", new { Id = item.Id })" class="btn btn-default"><span class='glyphicon glyphicon-pencil'></span></a>&nbsp;
                                <a href="@Url.Action("Delete", "AdminNewsAction", new { Id = item.Id })" class="btn btn-danger"><span class='glyphicon glyphicon-trash'></span></a>&nbsp;
                            </div>
                        </td>
                    </tr>
                    }
                </tbody>
            </table>
        }
    </div>
</div>
<script src="@Url.Content("/Scripts/plugins/dataTables/jquery.dataTables.js")"></script>
<script src="@Url.Content("/Scripts/plugins/dataTables/dataTables.bootstrap.js")"></script>
<script>
    $(document).ready(function () {
        $('#dataTables-example').dataTable();
    });
</script>